package com.yxw.yxnet_cd_center.customer_service.utils;


import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import com.yxw.yxnet_cd_center.common.utils.BaseDateTime;
/**
 *
 * @author Administrator
 */
public class ConfigInfor {

    /*
    private static String ServerIP = "";
    private static int ServerPort = 0;
    private static String CaptureServerIP = "";
    private static int CaptureServerPort = 37777;
    private static String CaptureUser = "";
    private static String CapturePassWord = "";
    private static String ResourcePath = "";
    */
    private static boolean Debug = false;
    private static final String AppName = "CustomerService";
    private static final String ErrorLogFileName = AppName + BaseDateTime.getShortDateString() + "MqttSendLog.txt";   

    public static String getAppRootPath()
    {
        return com.yxw.yxnet_cd_center.customer_service.CustomerServiceApplication.getAppCurrenDir();
    }
    private static String getConfigValue(String ConfigName)
    {
        String tmpstring = "";
        String file = getAppRootPath() + java.io.File.separator + AppName + java.io.File.separator + "config.properties";//System.getProperty("user.dir").trim()
        Properties prop=new Properties(); 
        try
        {
            File dir = new File(file);
            if(dir.exists())
            {
                FileInputStream oFileInputStream = new FileInputStream(file);
                prop.load(oFileInputStream); 
                tmpstring=prop.getProperty(ConfigName); 
                oFileInputStream.close();
            }
            else
            {
                ErrorLog.Log("ConfigInfor.getConfigValue:config.properties不存在!");
                tmpstring = "";
            }
        }
        catch(Exception e) 
        {
            ErrorLog.Log("ConfigInfor.getConfigValue"+e.getMessage());
            tmpstring = "";
        }
        return tmpstring;
    } 
    public static String getConfigFilePath()
    {
        //String tmpstring = "";
        String FilePath = getAppRootPath() + java.io.File.separator + AppName + java.io.File.separator;//System.getProperty("user.dir").trim()
        return FilePath;
    }
    public static String getErrorlogPath()
    {
        String filePath = getAppRootPath() + java.io.File.separator + AppName + java.io.File.separator + "errorlog"  + java.io.File.separator + BaseDateTime.getShortDateStringNoSlipt();
        try
        {
            File dir = new File(filePath);  
            if (!dir.exists()) 
            { 
                dir.mkdirs();// 不存在则创建   
            }            
        }
        catch(Exception e) 
        {
          e.printStackTrace();
        }
        return filePath;
    }    
    public static String getSaveFilePath()
    {
        String filePath = getAppRootPath() + java.io.File.separator + AppName + java.io.File.separator + "SaveFile";
        try
        {
            File dir = new File(filePath);  
            if (!dir.exists()) 
            { 
                dir.mkdirs();// 不存在则创建   
            }            
        }
        catch(Exception e) 
        {
          e.printStackTrace();
        }
        return filePath;
    }     
    public static String getLibsPath()
    {
        String filePath = getAppRootPath();// + java.io.File.separator + "libs";
        try
        {
            File dir = new File(filePath);  
            if (!dir.exists()) 
            { 
                dir.mkdirs();// 不存在则创建   
            }            
        }
        catch(Exception e) 
        {
          e.printStackTrace();
        }
        return filePath;
    }  
    public static boolean isDebug() {
        return Debug;
    }

    public static String getAppName() {
        return AppName;
    }  
    public static String getErrorLogFileName() {
        return ErrorLogFileName;
    } 
}